from nonebot import on_regex
from nonebot.typing import T_State
from nonebot.adapters.onebot.v11 import GroupMessageEvent, Bot, Message
from datetime import datetime
from nonebot import logger

# 监听所有消息，检测是否包含"ciallo"
Test_qwq = on_regex(pattern=r'(?i)ciallo', priority=1)

@Test_qwq.handle()
async def qwq_detect(bot: Bot, event: GroupMessageEvent, state: T_State):
    # Log the details of the message at the DEBUG level
    logger.debug(f"Received message from group {event.group_id} at {datetime.now()}: {event.message}")
    logger.debug(f"Sender: {event.sender.nickname} (User ID: {event.sender.user_id})")

    # 如果消息中包含"ciallo"，回复"ciallo～"
    await Test_qwq.finish(message=Message("Ciallo～(∠・ω< )⌒★"))


# from nonebot_plugin_alconna import Alconna, on_alconna
# from nonebot.adapters import Bot, Event
# from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment

# # Use a regex pattern for case-insensitive matching of 'ciallo' as a substring
# cmd = on_alconna(Alconna(r'(?i).*ciallo.*', namespace=""))  # (?i) makes it case-insensitive

# @cmd.handle()
# async def handle_command(bot: Bot, event: MessageEvent):
#     await cmd.send(MessageSegment.text("Ciallo～(∠・ω< )⌒★"))
